API Documentation
Environment.h
1 // Environment.h
3 //
5 
6 namespace nkScripts
7 {
13  class Environment final
14  {
15  public :
16 
25 
26  // Getters
35 
36  // Setters
42  void setEnvironmentFor (INTERPRETER interpretType) ;
50  void setName (const nkMemory::StringView& name) ;
51 
52  // Execution
59  bool execute (const Script& script) ;
64 
65  // Manipulating memory
72  void setVar (const nkMemory::StringView& name, bool value) ;
79  void setVar (const nkMemory::StringView& name, int value) ;
86  void setVar (const nkMemory::StringView& name, float value) ;
93  void setVar (const nkMemory::StringView& name, double value) ;
100  void setVar (const nkMemory::StringView& name, const char* value) ;
107  void setVar (const nkMemory::StringView& name, const nkMemory::StringView& value) ;
114  void setVar (const nkMemory::StringView& name, const ScriptObjectReference& value) ;
122  void setObject (const nkMemory::StringView& name, const nkMemory::StringView& userTypeName, void* value) ;
123 
129  bool isVarSet (const nkMemory::StringView& name) ;
130 
140  bool getVar (const nkMemory::StringView& name, bool defaultValue) ;
150  int getVar (const nkMemory::StringView& name, int defaultValue) ;
160  float getVar (const nkMemory::StringView& name, float defaultValue) ;
170  double getVar (const nkMemory::StringView& name, double defaultValue) ;
180  const nkMemory::StringView& getVar (const nkMemory::StringView& name, const nkMemory::StringView& defaultValue) ;
200  void* getObject (const nkMemory::StringView& name, const nkMemory::StringView& userTypeName = nullptr) ;
210 
226  bool isFuncSet (const nkMemory::StringView& name) ;
232 
248  bool isUserTypeSet (const nkMemory::StringView& name) ;
254 
275 
276  // Call C++ -> Script
285  bool callScriptFunction (const ScriptObjectReference& reference, const DataStack& args, DataStack& expectedOutput) ;
286 
296  nkMemory::Buffer serializeScriptObject (const ScriptObjectReference& reference, bool forwardUserDataOwnership = false) ;
304  } ;
305 }
306 
nkScripts::Environment::getFunc
Function * getFunc(const nkMemory::StringView &name)
nkScripts::Environment::Environment
Environment()
nkScripts::Environment
Defines an environment in which scripts can execute.
Definition: Environment.h:14
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, bool value)
nkScripts
Encompasses all API of component NilkinsScripts.
Definition: Environment.h:7
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, const ScriptObjectReference &value)
nkScripts::Namespace
Holds information and allow control over a namespace in a scripting environment.
Definition: Namespace.h:12
nkScripts::Script
Holds all information for a script.
Definition: Script.h:14
nkMemory::BufferView
A view over data.
Definition: BufferView.h:18
nkScripts::Environment::setEnvironmentFor
void setEnvironmentFor(INTERPRETER interpretType)
nkScripts::Environment::deserializeScriptObject
ScriptObjectReference deserializeScriptObject(const nkMemory::BufferView< unsigned char > &object)
nkScripts::Environment::setFunc
Function * setFunc(const nkMemory::StringView &name)
nkScripts::Environment::getScriptFunction
ScriptObjectReference getScriptFunction(const nkMemory::StringView &name)
nkScripts::Environment::getVar
int getVar(const nkMemory::StringView &name, int defaultValue)
nkScripts::Environment::getVar
double getVar(const nkMemory::StringView &name, double defaultValue)
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, int value)
nkScripts::Environment::getObject
void * getObject(const nkMemory::StringView &name, const nkMemory::StringView &userTypeName=nullptr)
nkScripts::Environment::isFuncSet
bool isFuncSet(const nkMemory::StringView &name)
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, const char *value)
nkScripts::Environment::getNamespace
Namespace * getNamespace(const nkMemory::StringView &name)
nkScripts::Environment::setNamespace
Namespace * setNamespace(const nkMemory::StringView &name)
nkScripts::Environment::isNamespaceSet
bool isNamespaceSet(const nkMemory::StringView &name)
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, float value)
nkScripts::UserType
Represents a user type and all the information and control related.
Definition: UserType.h:27
nkScripts::Environment::getVar
float getVar(const nkMemory::StringView &name, float defaultValue)
nkMemory::Buffer
A buffer holding binary data.
Definition: Buffer.h:32
nkScripts::Environment::getVar
const nkMemory::StringView & getVar(const nkMemory::StringView &name, const nkMemory::StringView &defaultValue)
nkScripts::ScriptObjectReference
A reference over an object in the scripting environment.
Definition: ScriptObjectReference.h:30
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, double value)
nkScripts::Environment::callScriptFunction
bool callScriptFunction(const ScriptObjectReference &reference, const DataStack &args, DataStack &expectedOutput)
nkScripts::Environment::isVarSet
bool isVarSet(const nkMemory::StringView &name)
nkScripts::Environment::setVar
void setVar(const nkMemory::StringView &name, const nkMemory::StringView &value)
nkScripts::Environment::setUserType
UserType * setUserType(const nkMemory::StringView &name)
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkScripts::Environment::getVar
bool getVar(const nkMemory::StringView &name, bool defaultValue)
nkScripts::Environment::getUserType
UserType * getUserType(const nkMemory::StringView &name)
nkScripts::ExecutionResult
Holds information about the execution result of a script in an environment.
Definition: ExecutionResult.h:26
nkScripts::INTERPRETER
INTERPRETER
Supported scripting environments.
Definition: Interpreter.h:12
nkScripts::Environment::setName
void setName(const nkMemory::StringView &name)
nkScripts::Environment::requestGarbageCollection
void requestGarbageCollection()
nkScripts::Environment::getVar
ScriptObjectReference getVar(const nkMemory::StringView &name)
nkScripts::Environment::isUserTypeSet
bool isUserTypeSet(const nkMemory::StringView &name)
nkScripts::Environment::getName
nkMemory::StringView getName() const
nkScripts::Environment::execute
bool execute(const Script &script)
nkScripts::Function
Holds information, and controls, over a function in a scripting environment.
Definition: Function.h:50
nkScripts::Environment::setObject
void setObject(const nkMemory::StringView &name, const nkMemory::StringView &userTypeName, void *value)
nkScripts::Environment::~Environment
~Environment()
nkScripts::Environment::serializeScriptObject
nkMemory::Buffer serializeScriptObject(const ScriptObjectReference &reference, bool forwardUserDataOwnership=false)
nkScripts::Environment::getLastExecutionResult
const ExecutionResult & getLastExecutionResult() const